class_name CustomTimerSystem
extends BaseSystem

## 自定义Timer系统

#region 属性
var next_timer_id:int = 0
var timer_dict:Dictionary = {}
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
func init_system(args = null):
	super(args)
#endregion
#region 公共方法
func create_timer(duration:float,repeat_count:int = 1) -> CustomTimer:
	var id = next_timer_id
	var timer:CustomTimer = CustomTimer.new(id,duration,repeat_count)
	timer_dict[id] = timer
	next_timer_id += 1
	return timer
func remove_timer(id:int):
	if timer_dict.has(id):
		timer_dict[id].destroy()
		timer_dict.erase(id)
func start_timer(id:int):
	if timer_dict.has(id):
		timer_dict[id].start_timer()
func start_all_timer():
	for timer:CustomTimer in timer_dict.values():
		timer.start_timer()
func stop_timer(id:int):
	if timer_dict.has(id):
		timer_dict[id].stop_timer()
func stop_all_timer():
	for timer:CustomTimer in timer_dict.values():
		timer.stop_timer()
func tick(delta: float):
	for timer:CustomTimer in timer_dict.values():
		timer.tick(delta)
#endregion
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _physics_process(delta: float) -> void:
	if enable:
		tick(delta)
#endregion
